"""开通资金监管账户（注册后）"""

from selenium.webdriver.common.by import By
from base.page_base import BasePage


class OpenFundAccount(BasePage):
    """开通资金托管"""

    # 元素定位
    __open_fund_account_btn = By.XPATH, '//*[text()="开通资金托管"]' # 开通资金托管按钮
    __name_input_box = By.NAME, 'realname' # 姓名输入框
    __idcard_input_box = By.NAME, 'card_id' # 身份证号输入框
    __submit_btn = By.CLASS_NAME, 'btn' # 确认提交按钮
    __immediate_open_btn = By.XPATH, '//input[@value="立即开通"]' # 立即开通按钮
    __assert_success_text = By.CSS_SELECTOR, 'body'

    def open_fund_account_click(self): # 点击开通资金托管按钮
        self.base_click(self.__open_fund_account_btn)

    def input_name(self,name): # 输入姓名
        self.base_input(self.__name_input_box,name)

    def input_idcard(self,idcard): # 输入身份证号
        self.base_input(self.__idcard_input_box,idcard)

    def submit_click(self): # 点击确认提交按钮
        self.base_js_click(self.__submit_btn)

    def immediate_open_click(self): # 点击立即开通按钮
        self.base_visible_click(self.__immediate_open_btn)

    def assert_open_fund_account_success(self): # 断言开通资金托管成功
        assert_text = self.base_switch_handle(self.__assert_success_text).text
        return assert_text

    def open_fund_account_process(self,name,idcard): # 开通资金托管全流程
        self.open_fund_account_click()
        self.input_name(name)
        self.input_idcard(idcard)
        self.submit_click()
        self.immediate_open_click()



